import Vue from 'vue';
import VueRouter from 'vue-router';

import login from '../components/login';
import register from '../components/register';

Vue.use(VueRouter);
const originalPush = VueRouter.prototype.push;
VueRouter.prototype.push = function push(location) {
  return originalPush.call(this, location).catch(err => err);
};

const routes = [
  {
    path: '/login',
    name: 'login',
    component: login,
  },
  {
    path: '/register',
    name: 'register',
    component: register,
  },
  {
    path: '',
    redirect: '/index',
  },
];
const router = new VueRouter({
  mode: 'history',
  base: process.env.NODE_ENV === 'production' ? '/shop' : '/',
  routes,
});
export default router;
